home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / mandel.arc / MANDSHOW.C < prev    next >
Text File  |  1987-03-11  |  6KB  |  193 lines

  1. /****************************************************************************/
  2. /* MODULE NAME:                                 */
  3. /*    MANDSHOW - Nmemonic "SHOW  MANDelbrot set"                            */
  4. /*                                        */
  5. /* MODULE DESCRIPTION:                                */
  6. /*    Colors, and displays a MANDelbrot image file for CGA.            */
  7. /*                                        */
  8. /* USAGE:                                    */
  9. /*    mandel  mandelbrot_image_file_name                    */
  10. /*                                        */
  11. /* INPUT:                                    */
  12. /*    FILE    fp    The mandelbrot image file name.             */
  13. /*                                        */
  14. /* PROCESS:  (Pseudo code)                            */
  15. /*     Initialize global constants.                        */
  16. /*     Define parameters.                            */
  17. /*     Begin MANDEL.                                */
  18. /*        Define local variables.                        */
  19. /*        --- Insert pseudo code here ---                    */
  20. /*     End MANDEL.                                */
  21. /*                                        */
  22. /* OUTPUT:                                    */
  23. /*                                        */
  24. /* EQUATIONS/ALGORITHMS:                            */
  25. /*                                        */
  26. /* REFERENCES:                                    */
  27. /*                                        */
  28. /****************************************************************************/
  29.  
  30. /*---> Standard definitions and declares <---*/
  31. #include <stdio.h>
  32. #include <dos.h>
  33.  
  34. /*---> Initialize global constants <---*/
  35. #define then
  36. #define begin {
  37. #define end }
  38. #define TRUE 1
  39. #define FALSE 0
  40. extern double atof() ;
  41.  
  42. main( ARGC, ARGV )
  43.  
  44.    /*---> Define Parameters <---*/
  45.    int             ARGC         ; /*                   */
  46.    char         *ARGV[]         ; /*                   */
  47.  
  48. begin    /*MANDEL*/
  49.  
  50.    /*---> Define Local Variables <---*/
  51.    FILE         *fp          ;
  52.    int             INDX      =  0  ; /* General purpose counter.       */
  53.    int             INDY      =  0  ; /* General purpose counter.       */
  54.    int             Z           =  0  ; /* Itteration value           */
  55.    int             XDOTS     =  0  ; /* Number of display pixles in X    */
  56.    int             YDOTS     =  0  ; /* Number of display pixles in Y    */
  57.    int             INTNO     =  0  ;
  58.    int             COLOR     =  0  ;
  59.    int             RET_CODE  =  0  ;
  60.    char         *IN_BUF    =  0  ;
  61.    double         N           = 0.0 ; /* Running sum of PELS computed       */
  62.    union REGS INREGS         ;
  63.    union REGS OUTREGS         ;
  64.  
  65.    /*---> Process runtime arguments <---*/
  66.    if( ARGC < 2 ) then begin
  67.       printf( "INVALID ARGUMENT COUNT of %d . . . . . .\n", ARGC-1 ) ;
  68.       printf( "Use :   mandshow  mandelbrot_image_file_name   \n" ) ;
  69.       return ;
  70.       end   /*if*/
  71.  
  72.    /*---> Open input file <---*/
  73.    fp = fopen( ARGV[1], "r" ) ;
  74.    if( fp == 0 ) then begin
  75.       printf("Open ERROR on input file  : %s \n", ARGV[1] ) ;
  76.       return ;
  77.       end   /*if*/
  78.  
  79.    /*---> Read X,Y dimensions <---*/
  80.    fgets( IN_BUF, 80, fp ) ;
  81.    XDOTS = atoi( IN_BUF ) ;
  82.    fgets( IN_BUF, 80, fp ) ;
  83.    YDOTS = atoi( IN_BUF ) ;
  84.  
  85.    /*---> Generate interrupt to set 320x200 color mode on CRT <---*/
  86.    INTNO       = 0x10 ;
  87.    INREGS.h.ah = 0x00 ;
  88.    INREGS.h.al = 0x04 ;
  89.    int86( INTNO, &INREGS, &OUTREGS ) ;
  90.  
  91.    /*---> Generate interrupt to set background color (0-Black) <---*/
  92.    INTNO       = 0x10 ;
  93.    INREGS.h.ah = 0x0b ;
  94.    INREGS.h.bh = 0x00 ;
  95.    INREGS.h.bl = 0x00 ;
  96.    int86( INTNO, &INREGS, &OUTREGS ) ;
  97.  
  98.    /*---> Generate interrupt to set color palette (1,2,3-RGY) <---*/
  99.    INTNO       = 0x10 ;
  100.    INREGS.h.ah = 0x0b ;
  101.    INREGS.h.bh = 0x01 ;
  102.    INREGS.h.bl = 0x00 ;
  103.    int86( INTNO, &INREGS, &OUTREGS ) ;
  104.  
  105.    /*---> Generate interrupt to set test pattern <---*/
  106.    INTNO       = 0x10             ;
  107.    INREGS.h.ah = 0x0c             ;
  108.    INREGS.h.al = 0             ;
  109.    INREGS.x.dx = 5             ;
  110.    INREGS.x.cx = 5             ;
  111.    int86( INTNO, &INREGS, &OUTREGS ) ;
  112.    INREGS.h.al = 1             ;
  113.    INREGS.x.dx = 7             ;
  114.    INREGS.x.cx = 7             ;
  115.    int86( INTNO, &INREGS, &OUTREGS ) ;
  116.    INREGS.h.al = 2             ;
  117.    INREGS.x.dx = 9             ;
  118.    INREGS.x.cx = 9             ;
  119.    int86( INTNO, &INREGS, &OUTREGS ) ;
  120.    INREGS.h.al = 3             ;
  121.    INREGS.x.dx = 11             ;
  122.    INREGS.x.cx = 11             ;
  123.    int86( INTNO, &INREGS, &OUTREGS ) ;
  124.  
  125.    /*---> Loop to compute each pixle column value on 2-D Complex grid <---*/
  126.    for( INDY=0; INDY < YDOTS; INDY++ ) begin
  127.       for( INDX=0; INDX < XDOTS; INDX++ ) begin
  128.  
  129.      /*---> Read value of pixle from input file <---*/
  130.      fgets( IN_BUF, 80, fp ) ;
  131.      COLOR = atoi( IN_BUF ) ;
  132.  
  133.      /*---> Generate interrupt to set current pixle <---*/
  134.      INTNO = 0x10 ;
  135.      INREGS.h.ah = 0x0c ;
  136.      INREGS.x.dx = INDY ;
  137.      INREGS.h.al = (char)COLOR       ;
  138.      INREGS.x.cx = INDX           ;
  139.      int86( INTNO, &INREGS, &OUTREGS ) ;
  140.  
  141.      end   /*for INDX*/
  142.       end   /*for INDY*/
  143.  
  144.    /*---> Pause for user response <---*/
  145.    getch() ;
  146.  
  147.    /*---> Loop to draw vertical grid <---*/
  148.    for( INDY=0; INDY < YDOTS; INDY++ ) begin
  149.       for( INDX=0; INDX < XDOTS; INDX += (XDOTS / 10) ) begin
  150.      INTNO = 0x10 ;
  151.      INREGS.h.ah = 0x0c ;
  152.      INREGS.x.dx = INDY ;
  153.      INREGS.h.al = 0x00 ;
  154.      INREGS.x.cx = INDX ;
  155.      int86( INTNO, &INREGS, &OUTREGS ) ;
  156.      end   /*for INDX*/
  157.       end   /*for INDY*/
  158.  
  159.    /*---> Loop to draw horizontal grid <---*/
  160.    for( INDY=0; INDY < YDOTS; INDY += (YDOTS / 10) ) begin
  161.       for( INDX=0; INDX < XDOTS; INDX++ ) begin
  162.      INTNO = 0x10 ;
  163.      INREGS.h.ah = 0x0c ;
  164.      INREGS.x.dx = INDY ;
  165.      INREGS.h.al = 0x00 ;
  166.      INREGS.x.cx = INDX ;
  167.      int86( INTNO, &INREGS, &OUTREGS ) ;
  168.      end   /*for INDX*/
  169.       end   /*for INDY*/
  170.  
  171.    /*---> Pause for user response <---*/
  172.    getch() ;
  173.  
  174.    /*---> Generate interrupt to set color palette (1,2,3-CMW) <---*/
  175.    INTNO       = 0x10 ;
  176.    INREGS.h.ah = 0x0b ;
  177.    INREGS.h.bh = 0x01 ;
  178.    INREGS.h.bl = 0x01 ;
  179.    int86( INTNO, &INREGS, &OUTREGS ) ;
  180.  
  181.    /*---> Pause for user response <---*/
  182.    getch() ;
  183.  
  184.    /*---> Generate interrupt to set 320x200 color mode on CRT <---*/
  185.    INTNO       = 0x10 ;
  186.    INREGS.h.ah = 0x00 ;
  187.    INREGS.h.al = 0x03 ;
  188.    int86( INTNO, &INREGS, &OUTREGS ) ;
  189.  
  190.    /*---> Exit <---*/
  191.    return ;
  192.    end     /* MANDSHOW */
  193.